package xju_3_4.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import xju_3_4.entity.User;
import xju_3_4.mapper.UserMapper;
import xju_3_4.service.UserService;

import java.util.ArrayList;
import java.util.List;

@Controller
public class UserController {
    @Autowired
    private UserService  userService;

    @RequestMapping("login")
    public ModelAndView login(String username, String password) {
        User user = userService.login(username, password);
        System.out.println(user);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("list");
        List<User> users = new ArrayList<>();
        users.add(user);
        modelAndView.addObject("users", users);
        return modelAndView;
    }
}
